1. Field of the Invention
This invention relates to an information processing apparatus and, more particularly, to an information processing apparatus for translating source code including dynamic variables into object code by a compiling process and converting the object code into an executable load module by a linking process in order to execute.
2. Description of the Related Art
Variables used in languages, such as FORTRAN or C, can be classified into two types by mode of arrangement into a memory at execution time: static variables and dynamic variables. The allocation of a static variable to a storage area is constant regardless of the process of executing a program. On the other hand, the allocation of a dynamic variable to a storage area is performed during executing a program.
When a program is described in such a language, the initial value of a variable used must be set. If a variable the initial value of which is not set is referred to, an unexpected error may occur because the value of the variable remains unfixed.
The same problem exists with an array. That is to say, with an array, an array subscript outside a declared scope means that an undefined area is referred to, so the same problem with the above case will arise.
Conventionally, the following two methods are generally used to check whether a variable not initialized is referred to (undefined variable reference check):
(1) An instruction to initialize a target variable to a predetermined value is added to a program and the judgement that an undefined variable is referred to is made in the case of the predetermined value being detected at the time of executing the program.
(2) A compiler substitutes a predetermined initial value for a target variable at compile time and the judgement that an undefined variable is used is made in the case of the value being detected at the time of executing a program.
Furthermore, the following two methods are generally used to check whether an array subscript outside a declared scope is referred to (array subscript check):
(3) A programmer directly refers to the contents of an array subscript by, for example, adding an instruction to print out an array subscript to a program and judges.
(4) A compiler detects an instruction to refer to an array from a program at compile time and adds new instructions before and behind the instruction in order to check whether an array subscript is within the proper scope.
In methods (1) and (3), a programmer needs to add a new instruction by manual input, which is troublesome.
In methods (2) and (4), a program needs to be recompiled, which is inefficient for a program that takes a long time to compile.
Moreover, in methods (2) and (4), the above dynamic variables cannot be initialized. This will now be described in detail
The allocation of a dynamic variable to a memory area is determined when a program is executed and where a dynamic variable is allocated is managed by an operating system (OS). Therefore, in order to initialize the contents of a dynamic variable to a predetermined value, it is necessary to know the memory area to which the dynamic variable was allocated by the OS. Conventionally, however, there has been no such method, so it has been difficult to initialize a dynamic variable to an arbitrary value.